<template>
  <div data-v-260efa53="" class="address-page">
    <ul data-v-260efa53="" class="address-box shopContact-pc-address-box">
      <li
        data-v-260efa53=""
        v-for="(item, index) in addresslist"
        :key="index"
        @click="handlechange(item)"
      >
        <div data-v-260efa53="" class="select-lbox shopContact-pc-select-lbox">
          <img
            data-v-260efa53=""
            :src="isdefualt==item.id? '' :''"
          />
        </div>
        <div data-v-260efa53="" class="address-left">
          <div
            data-v-260efa53=""
            class="address-tit shopContact-pc-address-tit"
          >
            <h1 data-v-260efa53="">{{ item.toName }}</h1>
            <span data-v-260efa53="">{{ item.phone }}</span>
            <!---->
          </div>
          <div
            data-v-260efa53=""
            class="address-txt shopContact-pc-address-tit"
          >
            <span data-v-260efa53=""
              >{{ item.provinceName }} {{ item.cityName }} {{ item.areaName }}
              {{ item.addressDetail }}</span
            >
          </div>
        </div>
        <router-link :to="'/children/addaddress/' + index">
          <div data-v-260efa53="" class="address-edit">
            <span data-v-260efa53="">编辑</span>
          </div>
        </router-link>
      </li>
    </ul>
    <router-link to="/children/addaddress/-1">
      <div data-v-260efa53="" class="q-fix">
        <div data-v-260efa53="" class="q-fix-btn">
          <span data-v-260efa53="">新增收货地址</span>
        </div>
      </div>
    </router-link>
  </div>
</template>

<script>
import { getaddresslist, editdefaultaddress } from "../../api/zl-goods";
export default {
  data() {
    return {
      addresslist: [],
      isdefualt:0
    };
  },
  created() {
    getaddresslist().then((res) => {
      this.addresslist = res.data.data;
    });
    this.isdefualt = this.$route.query.id;
  },
  methods: {
    handlechange(item) {
        this.isdefualt = item.id;
      let { id, provinceName, cityName, areaName, toName, phone, province,addressDetail } =
        item;
      let o = {
        id: id,
        fullAddress: provinceName + cityName + areaName + addressDetail,
        receiverName: toName,
        mobile: phone,
        provCode: province,
      };
      editdefaultaddress(o).then((res) => {
        this.$router.push(this.$route.query.target);
      });
    },
  },
};
</script>

<style lang="less" scoped>
</style>